<template>
    <div class="pageitem">
        <div class="nav">
            <div>
                <slot name="icon"></slot><span class="title">{{title}}</span>
            </div>
            <div>更多 > </div>
        </div>
        <div class="container">
            <div v-for="item of data" :key="item.id">
                <div class="item" @click="handleItem(item.id)">
                    <div class="cover">
                        <div class="play-count">
                            <img src="../../../assets/images/p0.png" class="icon"><span>{{item.playCount | formatCount}}</span>
                        </div>
                        <img :src="item.coverImgUrl">
                    </div>
                    <p>{{item.name}}</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { parse } from 'path'
    export default {
        props:{
            title:{
                type:String
            },
            data:{
                type:Array
            }
        },
        filters:{
            formatCount(count){
                if(count>100000){
                    return parseInt(count/10000)+"万";
                }
                return count;
            }
        },
        methods:{
            handleItem(id){
                console.log(id);
                this.$router.push(`/playlist?id=${id}`);
            }
        }
    }
</script>

<style lang="less" scoped>
    .pageitem{
        padding-bottom: 10px;
    }
    .nav{
        font-size: 15px;
        border-top: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        padding: 10px 10px 0 10px;
    }
    .container{
        display: flex;
        flex-wrap: wrap;
        justify-content: space-evenly;
    }
    .play-count{
        position: absolute;
        right: 0;
        top: 2.5px;
        color: #fff;
        .icon{
            width: 12px;
            height: 12px;
        }
    }
    .item{
        width: 115px;
        position: relative;
        margin-top: 10px;
        font-size: 14px;
    }
    .cover{
        img{
            width: 115px;
            height: 115px;
        }
    }
    .title{
        // line-height: 33px;
    }
</style>